import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    //kjq
    {
      path: "/", //登入页面
      name: "login",
      component: () => import("../views/Login.vue"),
    },
    //登录之后页面
    {
      path: "/shouye", //首页页面
      name: "shouye",
      component: () => import("../views/Shouye.vue"),
      children:[
        //wcx
        {
          path: "/shouye/wcx", 
          name: "wcx",
          component: () => import("../views/wcx/shouye.vue"),
        },
        //ch
        {
          path: "/shouye/ch", 
          name: "ch",
          component: () => import("../views/ch/index.vue"),
        },
        //wmm
        {
          path: "/shouye/wmm", 
          name: "wmm",
          component: () => import("../views/wmm/index.vue"),
        },
        //jsj
        {
          path: "/shouye/jsj", 
          name: "jsj",
          component: () => import("../views/jsj/index.vue"),
        },
        //axl
        {
          path: "/shouye/axl", 
          name: "axl",
          component: () => import("../views/axl/index.vue"),
        },
      ]
    },
    {
      path: '/',
      redirect:'/login'
    }
    // {
    //   path: '/pinia',
    //   name: 'pinia',
    //   component: () => import('../components/pinia.vue')
    // },
  ]
})

//守卫
    // router.beforeEach((to, from, next) => {
    //   const token = sessionStorage.getItem('token',111)
    //   if (to.name !== 'wo' && !token) {
    //     // 如果用户未登录且不是访问登录页，则跳转到登录页
    //     next({ name: 'wo' })
    //   } else if (to.name === 'wo' && token) {
    //     // 如果用户已登录且访问登录页，则跳转到首页
    //     next({ name: 'shouye' })
    //   } else {
    //     // 其他情况放行
    //     next()
    //   }
    // })
export default router
